package com.example.userwallet.controller;

import com.example.userwallet.req.WalletQueryReq;
import com.example.userwallet.resp.CommonResp;
import com.example.userwallet.resp.WalletQueryResp;
import com.example.userwallet.service.WalletService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/wallet")
public class WalletController {

    @Resource
    WalletService service;

    // 查询用户钱包余额接口
    @GetMapping("/account")
    public CommonResp<WalletQueryResp> getAccount(WalletQueryReq req){
        CommonResp<WalletQueryResp> resp = new CommonResp<>();
        resp.setContent(service.getAccount(req));
        return resp;
    }

    // 用户消费100元
    @GetMapping("/consume100")
    public void consume(){
        service.consume();
    }
    // 用户退款20元
    @GetMapping("/drawback20")
    public void drawback(){
        service.drawback();
    }
}
